import {
  request,
  METHOD
} from '@/utils/request'

import axios from 'axios'
import Cookie from 'js-cookie'
const BASE_URL = process.env.VUE_APP_API_URL
/**
  /*
  维修配件单位
  */
export async function dictRepairUnits () {
  return request(`${BASE_URL}/business/admin/dict/repairUnits`, METHOD.GET)
}
// 维修配件列表
export async function repairUnitsList (params) {
  return request(`${BASE_URL}/business/admin/repairUnits`, METHOD.GET, params)
}
export async function listAccessoriesAndBrand (params) {
  return request(`${BASE_URL}/business/admin/accessories/listAccessoriesAndBrand`, METHOD.GET, params)
}
// 运维-配件库-配件详情-查看配件
export async function listAccessoriesAndBrandDetail (id) {
  return request(`${BASE_URL}/business/admin/accessories/detail/${id}`, METHOD.GET)
}
//  运维-配件库查询配件品类信息，查询所有配件品类名和编号
export async function getAccessoriesNoList () {
  return request(`${BASE_URL}/business/admin/accessories/listAll`, METHOD.GET)
}
// 运维-配件库-配件详情-查看配件
export async function getBrandNoList () {
  return request(`${BASE_URL}/business/admin/accessories/listAllBrand`, METHOD.GET)
}
// 新增维修配件
export async function repairUnitsAdd (params) {
  return request(`${BASE_URL}/business/admin/repairUnits`, METHOD.POST, params)
}
// 新增维修配件1.4.1
export async function createAccessoriesAndBrand (params) {
  return request(`${BASE_URL}/business/admin/accessories/createUpdateAccessoriesBrand`, METHOD.POST, params)
}
// 查询车辆型号
export async function getAllModels () {
  return request(`${BASE_URL}/business/inner/vehicleModels/getAllModels`, METHOD.GET)
}
// 编辑维修配件
export async function repairUnitsEdit (id, params) {
  return request(
    `${BASE_URL}/business/admin/repairUnits/${id}`,
    METHOD.PUT,
    params
  )
}
export async function repairUnitsDetail (id) {
  return request(
    `${BASE_URL}/business/admin/repairUnits/${id}`,
    METHOD.GET
  )
}
// 维修配件启用禁用
export async function repairUnitsEnableOrDisable (params) {
  return request(
    `${BASE_URL}/business/admin/accessories/enableOrDisable`,
    METHOD.POST,
    params
  )
}

// 调度单1.4.0 骑圈）分页查询(骑圈后台，小程序调度单与调度记录)
export async function vehicleDispatchList (params) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/list`, METHOD.GET, params)
}
// 调度单1.4.0 商户）车辆调度撤回
export async function withdrawDispatchOrder (params) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/withdrawDispatchOrder`, METHOD.POST, params)
}
// 出库单首页管理列表查询
export async function BoundDetail (id) {
  return request(`${BASE_URL}/business/admin/bound/${id}`, METHOD.GET)
}
// 出库单首页管理列表查询
export async function vehicleShelfApplyDetail (id) {
  return request(`${BASE_URL}/business/admin/vehicleShelfApply/${id}`, METHOD.GET)
}
// 意见反馈详情
export async function feedBackDetail (id) {
  return request(`${BASE_URL}/member/admin/members/feedBack/${id}`, METHOD.GET)
}
// 查看调度详情
export async function selectDispatchByIdDetail (id) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/selectDispatchById/${id}`, METHOD.GET)
}
// 出库单添加车牌号检测&&信息查询返回 （小程序拍照查，后管添加查
export async function addLicense (params) {
  return request(`${BASE_URL}/business/admin/bound/addLicense`, METHOD.POST, { ...params, source: 'admin' })
}
//
export async function addVehicleDispatchLicense (params) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/addLicense`, METHOD.POST, params)
}
// 出库单单条新
export async function addBound (params) {
  return request(`${BASE_URL}/business/admin/bound`, METHOD.POST, params)
}

export async function addBoundGet (id) {
  return request(`${BASE_URL}/business/admin/bound/${id}`, METHOD.GET)
}
export async function addBoundEdit (id, params) {
  return request(`${BASE_URL}/business/admin/bound/${id}`, METHOD.PUT, params)
}

// 车辆-出库管理-新增-获取仓库下的车辆数 1.7.1 WYJ
export async function getInboundNum (warehouseId) {
  return request(`${BASE_URL}/business/admin/bound/getInboundNum/${warehouseId}`, METHOD.POST)
}

// 调度
export async function addScheduling (params) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch`, METHOD.POST, params)
}

export async function addSchedulingGet (id) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/${id}`, METHOD.GET)
}
export async function addSchedulingEdit (id, params) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/${id}`, METHOD.PUT, params)
}
// 配件申请审核详情

export async function getPartsReviewDetail (id, data) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesApply/${id}`, METHOD.GET, data)
}
// 查询配件明细
export async function getApplyItemInfo (id) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesApplyItemDetails/getByApplyItemId/${id}`, METHOD.GET)
}
// 单个配件申请单物流信息查询
export async function getApplyItemLogisticsInfo (id) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesLogistics/${id}`, METHOD.GET)
}
// 骑手详情  骑手基本信息
export async function getRiderDefaultInfo (id) {
  return request(`${BASE_URL}/member/admin/members/${id}`, METHOD.GET)
}
// 骑手详情  骑手履历信息
export async function getRiderRecord (id) {
  return request(`${BASE_URL}/member/admin/members/${id}/infoStatistics`, METHOD.GET)
}
// 骑手履历 套餐订单
export async function getSetOrderList (params) {
  return request(`${BASE_URL}/order/admin/packageOrder/list`, METHOD.GET, params)
}
// 骑手履历  换电卡订单
export async function getChangeBatteryList (params) {
  return request(`${BASE_URL}/order/hq/admin/regularDinner/riderRegularDinnerPaging`, METHOD.GET, params)
}
// 骑手履历  换电记录

export async function getChangeBatteryRecordList (params) {
  return request(`${BASE_URL}/order/admin/list/batteryUse/byCondition`, METHOD.GET, params)
}
// 骑手履历  优惠券记录
export async function getCouponRecordList (params) {
  return request(`${BASE_URL}/promotion/admin/coupons/fetchAllByUserId`, METHOD.GET, params)
}
// 骑手履历  维修记录
export async function getRepairOrderList (params) {
  return request(`${BASE_URL}/todo/admin/repairOrders`, METHOD.GET, params)
}
// 骑手履历  积分记录
export async function getPointRecordList (params) {
  return request(`${BASE_URL}/member/admin/memberPoints/fetchAllByMemberId`, METHOD.GET, params)
}
// 骑手履历  反馈记录
export async function getFeedbackRecordList (params) {
  return request(`${BASE_URL}/member/admin/members/feedBack/list`, METHOD.GET, params)
}
// 骑手履历  租车订单
export async function getVehicleOrderRecordList (params) {
  return request(`${BASE_URL}/order/admin/vehicleOrder/list`, METHOD.GET, params)
}
// 骑手履历  租车订单new
export async function getVehicleOrderRecordListNew (params) {
  return request(`${BASE_URL}/order/admin/vehicleOrder/list/all`, METHOD.GET, params)
}
// 骑手履历  换车记录
export async function getChangeCarList (id, params) {
  return request(`${BASE_URL}/order/admin/vehicleOrderChange/listByUser/${id}`, METHOD.GET, params)
}
// 当前车/电信息  租车订单
export async function getVehicleOrderList (params) {
  return request(`${BASE_URL}/order/admin/vehicleOrder/findUsingOrderByUserId`, METHOD.GET, params)
}
// 当前车/电信息  换电订单
export async function getNowBattaryOrder (id) {
  return request(`${BASE_URL}/order/hq/admin/regularDinner/findLatestOrder/${id}`, METHOD.GET)
}
// 查看骑手操作记录
export async function getOperatRecord (params) {
  return request(`${BASE_URL}/member/admin/memberOperateLog`, METHOD.GET, params)
}
// 手动录积分
export async function inputPoints (params) {
  return request(`${BASE_URL}/member/admin/memberPoints/inputPointsManually`, METHOD.POST, params)
}
// 维修工单加入跟进
export async function followUp (orderId) {
  return request(`${BASE_URL}/order/admin/orderTrackLog/createOrderTrackLog/${orderId}`, METHOD.POST)
}

// 配件申请-签收
export async function partsSign (id, params) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesApply/sign/${id}`, METHOD.PUT, params)
}

// 配件发货单签收
export async function partsSignDispatch (id, params) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesDispatch/sign/${id}`, METHOD.PUT, params)
}

// 关闭配件申请单
export async function partsClose (params) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesApply/close`, METHOD.POST, params)
}

// 配件申请审核-添加配件
export async function storeAccessoriesApply (params) {
  return request(`${BASE_URL}/business/admin/storeAccessoriesApply`, METHOD.POST, params)
}
// 创建维修单-根据车牌号查询租车订单号
export async function findFinishOrderByVehicleId (vehicleId) {
  return request(`${BASE_URL}/order/admin/vehicleOrder/findFinishOrderByVehicleId/${vehicleId}`, METHOD.GET)
}
// 车辆管理-出库单管理-新增-根据门店ID查询结算账号
export async function findOneByStoreId (params) {
  return request(`${BASE_URL}/order/admin/settlementAccount/findOneByStoreId`, METHOD.GET, params)
}
// 车辆管理-出库单管理-新增-设置支付宝账号
export async function updateAlipayAccount (params) {
  return request(`${BASE_URL}/order/admin/settlementAccount/updateAlipayAccount`, METHOD.POST, params)
}
// 配件采购-所有配件+品牌
export async function partsBrandListAll () {
  return request(`${BASE_URL}/business/admin/accessories/listAccessoriesAndBrandAll`, METHOD.GET)
}

// 配件采购单-列表
export async function partsBuyList (params) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase`, METHOD.GET, params)
}

// 配件采购-新增-配件品类+品牌
export async function partsBrandList (params) {
  return request(`${BASE_URL}/business/admin/accessories/listAccessoriesAndBrand`, METHOD.GET, params)
}
// 配件采购-新增-提交
export async function addPartsSubmit (params) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase`, METHOD.POST, params)
}
// 配件采购单-查看-获取单个采购单
export async function partsBuyItemDetail (id) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase/${id}`, METHOD.GET)
}
// 配件采购单-查看-采购明细
export async function partsBuySeeDetail (data) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchaseItem`, METHOD.GET, data)
}
// 配件采购单-查看-日志
export async function partsBuyLogDetail (data) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchaseLog`, METHOD.GET, data)
}

// 配件采购单-收货确认
export async function partsBuyTakeConffrim (id, data) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase/receiveConfirm/${id}`, METHOD.PUT, data)
}

// 配件采购单上传
export async function putInAccessoriesPurchaseImportant (data) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase/upload`, METHOD.POST, data)
}
// 配件采购单删除
export async function deletePartsItem (id) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase/${id}`, METHOD.DELETE)
}
// 配件采购单收货-修改-回显查询
export async function partsBuyTakeDetail (id) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase/queryForUpdate/${id}`, METHOD.GET)
}
// 配件采购单-修改-提交
export async function editPartsItem (id, data) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchase/${id}`, METHOD.PUT, data)
}

// 配件统计-列表
export async function partsStatList (params) {
  return request(`${BASE_URL}/business/admin/AdsDecAccessoriesAmount/stat`, METHOD.GET, params)
}

// 配件统计查询所有配件
export async function allPartsList () {
  return request(`${BASE_URL}/statistical/admin/AdsDecAccessoriesAmount/accessoryNames`, METHOD.GET)
}
// 配件统计-已出库统计
export async function outboundStatistics (data) {
  return request(`${BASE_URL}/business/admin/AdsDecAccessoriesAmount/out/detail`, METHOD.GET, data)
}
// 配件统计-已使用统计
export async function usedStatistics (data) {
  return request(`${BASE_URL}/business/admin/AdsDecAccessoriesAmount/using/detail`, METHOD.GET, data)
}

// 配件采购单模板下载
export async function getTemplateDownload () {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/business/admin/accessoriesPurchase/templateDownload`,
    responseType: 'blob'
  })
}

// 修改维修工单
export async function editRepairOrder (id, data) {
  return request(`${BASE_URL}/todo/admin/repairOrders/${id}/updateRepairOrder`, METHOD.POST, data)
}
// 维修工单修改记录
export async function editRepairOrderLogs (id, data) {
  return request(`${BASE_URL}/todo/admin/repairOrders/${id}/updateRepairOrderLog`, METHOD.POST, data)
}

// 配件统计导出
export const unitsStatExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/AdsDecAccessoriesAmount/export`,
    responseType: 'blob',
    params
  })
}
// 巡店记录列表
export async function patrolStoreList (data) {
  return request(`${BASE_URL}/todo/patrolStore/admin/list`, METHOD.GET, data)
}
// 巡店记录详情
export async function patrolStoreDetail (data) {
  return request(`${BASE_URL}/todo/patrolStore/admin/detail/list`, METHOD.GET, data)
}
// 申请单列表 1.5.9
export async function backtrackApply (data) {
  return request(`${BASE_URL}/business/admin/backtrackApply`, METHOD.GET, data)
}
// 返件申请单详情 1.5.9
export async function backtrackApplyDetail (id) {
  return request(`${BASE_URL}/business/admin/backtrackApply/${id}`, METHOD.GET)
}

// 返厂列表 1.5.9
export async function backtrackApplyReturns (data) {
  return request(`${BASE_URL}/business/admin/backtrackApply/returns`, METHOD.GET, data)
}

// 返厂详情 1.5.9
export async function backtrackApplyReturnsDetail (returnsNo) {
  return request(`${BASE_URL}/business/admin/backtrackApply/returns/${returnsNo}`, METHOD.GET)
}
// 配件库导出
export const partsListExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/accessories/export`,
    responseType: 'blob',
    params
  })
}
// 查询调度提示
export async function dispatchQueryMag (data) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/queryMsg`, METHOD.POST, data)
}
// 查询出库提示
export async function outStoreQueryMag (data) {
  return request(`${BASE_URL}/business/admin/bound/queryMsg`, METHOD.POST, data)
}
// 查看配件编码
export async function getAccessoriesCode (params) {
  return request(`${BASE_URL}/business/admin/accessoriesPurchaseItem/accessories`, METHOD.GET, params)
}
// 批量设置采购价-163
export async function setSomePartsPur (params) {
  return request(
    `${BASE_URL}/business/admin/accessories/purchasePrice/batch`,
    METHOD.PUT,
    params
  )
}
// 配件进出库统计-总统计
export async function partsOutAndInStat (params) {
  return request(`${BASE_URL}/business/admin/AdsDecAccessoriesAmount/total/stat`, METHOD.GET, params)
}
// 配件进出库统计-入库统计
export async function partsInStat (params) {
  return request(`${BASE_URL}/business/admin/AdsDecAccessoriesAmount/in/stat`, METHOD.GET, params)
}
// 配件进出库统计-出库统计
export async function partsOutStat (params) {
  return request(`${BASE_URL}/business/admin/AdsDecAccessoriesAmount/out/stat`, METHOD.GET, params)
}
// 配件进出库统计-总统计-导出
export const partsOutAndInExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/AdsDecAccessoriesAmount/total/stat/export`,
    responseType: 'blob',
    params
  })
}
// 配件进出库统计-出库统计-导出
export const partsOutExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/AdsDecAccessoriesAmount/out/stat/export`,
    responseType: 'blob',
    params
  })
}
// 配件进出库统计-入库统计-导出
export const partsInExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/AdsDecAccessoriesAmount/in/stat/export`,
    responseType: 'blob',
    params
  })
}
// 平台维修获取配件申请

export async function plantPartsDetail (id) {
  return request(`${BASE_URL}/todo/admin/repairOrders/${id}`, METHOD.GET)
}
// 新增调度单-上传关联图片
export function uploadDispatchPic () {
  return `${BASE_URL}/business/admin/vehicleDispatch/uploadPic`
}
//  1.6.8 根据手机号查询 租车订单
export async function getPhoneSearchOrder (params) {
  return request(`${BASE_URL}/order/admin/vehicleOrder/currentInUseList`, METHOD.GET, params)
}

// 1.6.8定损单
// 定损单列表
export async function damageOrder (params) {
  return request(`${BASE_URL}/order/admin/lossAssessmentOrder/list`, METHOD.GET, params)
}
// 定损单删除
export async function deleteDamageOrder (id) {
  return request(`${BASE_URL}/order/admin/lossAssessmentOrder/delete/${id}`, METHOD.DELETE)
}
// 定损单详情
export async function damageOrderDetail (id) {
  return request(`${BASE_URL}/order/admin/lossAssessmentOrder/detail/${id}`, METHOD.GET)
}
// 调整定损单支付状态
export async function damageOrderUpdate (data) {
  return request(`${BASE_URL}/order/admin/lossAssessmentOrder/updatePayStatus`, METHOD.POST, data)
}
// 导出定损单
export const damageOrderExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/order/admin/lossAssessmentOrder/export`,
    responseType: 'blob',
    params
  })
}

// 仓库调度

// 车辆管理-仓库调度-列表 1.7.1 WYJ
export async function warehouseVehicleDispatchList (params) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/pageList`, METHOD.GET, params)
}

// 车辆管理-仓库调度-新增 1.7.1 WYJ
export async function warehouseVehicleDispatchInfoInsert (data) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/insert`, METHOD.POST, data)
}

// 车辆管理-仓库调度-列表-新增-获取导入模板 1.7.1 WYJ
export const getVinNoExcelTemplate = () => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/getVinNoExcelTemplate`,
    responseType: 'blob'
  })
}

// 车辆管理-仓库调度-列表-新增-导入车架号验证 1.7.1 WYJ
export async function uploadVinNoByExcel (data) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/uploadVinNoByExcel`, METHOD.POST, data)
}

// 车辆管理-仓库调度-列表-新增-文本格式添加车辆 1.7.1 WYJ
export async function warehouseVehicleDispatchCheckVehicle (params) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/checkVehicle`, METHOD.POST, params)
}

// 车辆管理-仓库调度-列表-查看 1.7.1 WYJ
export async function warehouseVehicleDispatchInfoDetail (id) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/detail/${id}`, METHOD.GET)
}

// 车辆管理-仓库调度-列表-查看-调出车辆明细 1.7.1 WYJ
export async function warehouseVehicleDispatchVehicleInfo (id) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/detail/vehicleInfo/${id}`, METHOD.GET)
}

// 车辆管理-仓库调度-详情-关闭调度单 1.7.1 WYJ
export async function warehouseVehicleDispatchInfoClose (params) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/close`, METHOD.POST, params)
}

// 车辆管理-仓库调度-列表-查看-发货信息 1.7.1 WYJ
export async function warehouseVehicleDispatchDeliveryInfo (id) {
  return request(`${BASE_URL}/business/admin/warehouseVehicleDispatchInfo/detail/deliveryInfo/${id}`, METHOD.GET)
}

// 车辆-出库管理-列表-详情-物流详情
export async function getBoundLogisticsDetail (logisticsNo) {
  return request(`${BASE_URL}/business/admin/bound/getLogisticsDetail/${logisticsNo}`, METHOD.GET)
}

// 车辆-调度管理-列表-详情-物流详情
export async function getVehicleDispatchLogisticsDetail (logisticsNo) {
  return request(`${BASE_URL}/business/admin/vehicleDispatch/getLogisticsDetail/${logisticsNo}`, METHOD.GET)
}

// 车辆-调度管理-门店调度-导出 WYJ
export const vehicleDispatchExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/vehicleDispatch/export`,
    responseType: 'blob',
    params
  })
}
// 车辆-调度管理-调度回库-导出 WYJ
export const vehicleDispatchRestockExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/vehicleDispatch/restock/export`,
    responseType: 'blob',
    params
  })
}
